#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
const int maxn = 10+5;
struct dice{
    int r, c, t, f;
    dice *p;
    dice(int r, int c, int t, int f, dice *p= nullptr):r(r), c(c), t(t), f(f), p(p){}
};
int R, C, r0, c0, t0, f0;
int G[maxn][maxn];
bool vis[maxn][maxn][7][7];
int rig[7][7], to[7];
dice *d0;

pii go(int T, int F, char c){
    int t = T, f = F;
    switch (c){
        case 'L':{
            T = rig[T][F];
            break;
        }
        case 'R':{
            T = to[rig[T][F]];
            break;
        }
        case 'U':{
            T = f;
            F = to[t];
            break;
        }
        case 'D':{
            F = t;
            T = to[f];
            break;
        }
    }
    return make_pair(T, F);
}

inline bool in(int r, int c){
    return r>=1 && r<=R && c>=1 && c<=C;
}
const char dir[] = "UDLR";
int dr[] = {-1, 1, 0, 0,};
int dc[] = {0, 0, -1, 1,};

bool dfs(dice *d){
    int r=d->r, c=d->c, t=d->t, f=d->f;

    if(r==r0 && c==c0 && vis[r0][c0][t0][f0]) {d0->p = d->p; return true;}
    else if(vis[r][c][t][f]) return false;
    else vis[r][c][t][f] = true;

    for (int i = 0; i < 4; ++i) {
        pii pa = go(t, f, dir[i]);
        int t1 = pa.first, f1 = pa.second;
        int r1 = r+dr[i], c1 = c+dc[i];


        if(in(r1, c1) && (G[r1][c1]==-1 || G[r1][c1]==t)){
            dice *d1 = new dice(r1, c1, t1, f1, d);
            if(dfs(d1)) return true;
        }
    }
    return false;
}

void init(){
    memset(G, 0, sizeof(G));
    memset(vis, false, sizeof(vis));
    to[1] = 6; to[6] = 1; to[2] = 5; to[5] = 2; to[3] = 4; to[4] = 3;

    rig[1][2]=3, rig[1][3]=5, rig[1][5]=4, rig[1][4]=2;
    rig[2][1]=4, rig[2][4]=6, rig[2][6]=3, rig[2][3]=1;
    rig[3][1]=2, rig[3][2]=6, rig[3][6]=5, rig[3][5]=1;
    rig[4][1]=5, rig[4][5]=6, rig[4][6]=2, rig[4][2]=1;
    rig[5][1]=3, rig[5][3]=6, rig[5][6]=4, rig[5][4]=1;
    rig[6][2]=4, rig[6][4]=5, rig[6][5]=3, rig[6][3]=2;
}
int main() {
    //ios_base::sync_with_stdio(false);cin.tie(nullptr);
    string name;
    while(cin >> name && name!="END"){
        init();
        cin >> R >> C >> r0 >> c0 >> t0 >> f0;
        d0 = new dice(r0, c0, t0, f0);
        for (int r = 1; r <= R; ++r) {
            for (int c = 1; c <= C; ++c) {
                cin >> G[r][c];
            }
        }
        cout << name << '\n';
        if(!dfs(d0)) cout << "  No Solution Possible\n";
        else {
            vector<int> x, y;
            x.push_back(d0->r); y.push_back(d0->c);
            for(dice *p=d0->p; p!=d0; p=p->p){
                x.push_back(p->r);
                y.push_back(p->c);
                //delete(p);
            }
            x.push_back(d0->r); y.push_back(d0->c);
            delete(d0);
            reverse(x.begin(), x.end()); reverse(y.begin(), y.end());
            for (int i = 1; i <=x.size() ; ++i) {
                if(i%9==1) cout << "  ";
                cout << "(" << x[i-1] << "," << y[i-1] << ")";
                if(i!=x.size()) cout << ",";
                if(i%9 == 0) cout <<  "\n";
            }
            if(x.size()%9) cout << "\n";
        }
    }
    return 0;
}